<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('attendance_shifts', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('company_id')->default(0)->index();
            $table->string('name', 50)->comment('班次名称（如早班、中班）');
            $table->time('in_time')->comment('上班打卡时间');
            $table->time('out_time')->comment('下班打卡时间');
            $table->smallInteger('in_flexible_minutes')->default(30)->comment('上班弹性时间（分钟）');
            $table->smallInteger('out_flexible_minutes')->default(30)->comment('下班弹性时间（分钟）');
            $table->time('late_threshold')->comment('迟到阈值时间');
            $table->time('early_leave_threshold')->comment('早退阈值时间');
            $table->tinyInteger('is_default')->default(0)->comment('是否默认班次（0-否，1-是）');
            $table->string('description')->nullable()->comment('班次描述');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('attendance_shifts');
    }
};
